﻿using System;

namespace Mjollnir
{
    public static class Ruby
    {
        public static void Unless(bool condition, Action @then)
        {
            if (@then == null) throw new ArgumentNullException("@then");

            if (!condition)
            {
                @then();
            }
        }

        public static void Unless<T>(bool condition, Action @then, Action @else)
        {
            if (@then == null) throw new ArgumentNullException("@then");
            if (@else == null) throw new ArgumentNullException("@else");

            if (!condition)
            {
                @then();
            }
            else
            {
                @else();
            }
        }

        public static TResult Unless<TResult>(bool condition, Func<TResult> @then, Func<TResult> @else)
        {
            if (@then == null) throw new ArgumentNullException("@then");
            if (@else == null) throw new ArgumentNullException("@else");

            return (!condition) ? @then() : @else();
        }
    }
}
